<?php
declare(strict_types=1);

namespace SixShop\Balpay\Hook;

use app\model\User;
use SixShop\Core\Attribute\Hook;
use SixShop\Payment\Event\GatheringPaymentEvent;
use SixShop\Payment\PaymentInfo;

class BalpayHook
{

    /**
     * 上报提供的支付服务信息
     */
    #[Hook(GatheringPaymentEvent::class)]
    public function paymentInfoSubmission(GatheringPaymentEvent $event): PaymentInfo
    {
        return new PaymentInfo(
            'balpay',
            '余额支付',
            '余额支付',
            params: [
                'balance' => (float)User::where('id', $event->request->userID)->value('balance'),
            ]
        );
    }
}